<template>
  <section class="toast" :class="toast.show ? 'fadeIn' : 'fadeOut'">
    <div class="icon_wrap" :class="toast.icon ? 'show_icon' : 'icon_none'" v-if="toast.icon">
      <i class="iconfont" :class="toast.icon"></i>
    </div>
    <span class="text" v-if="toast.message.constructor.name !== 'Array'">{{toast.message}}</span>
    <div class="text double_text" v-else>
      <span>{{toast.message[0]}}</span>
      <span>{{toast.message[1]}}</span>
      <span>{{toast.message[2]}}</span>
      <span>{{toast.message[3]}}</span>
    </div>
  </section>
</template>

<script>
import { mapState } from 'vuex';
export default {
  name: 'toast',
  computed: {
    ...mapState([
      'toast'
    ])
  }
};
</script>

<style lang="scss" scoped>
  @import '../style/mixin.scss';
  .toast {
    position: fixed;
    z-index: 98;
    left: 50%;
    top: 50%;
    max-width: 76%;
    min-width: 30%;
    // width: max-content;
    line-height: 1.6;
    padding: 0 14px;
    transform: translate(-50%, -50%);
    border-radius: 12px;
    background-color: rgba(0,0,0,.6);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    z-index: 99;
    &.icon_wrap {
      padding: 20px 14px 0;
      border-radius: 12px;
      display: flex;
      justify-content: center;
      align-items: center;
      .text {
        font-size: 30px;
        line-height: 2.2;
        color: #fff;
        position: relative;
        top: -10px;
      }
    }
    .iconfont {
      font-size: 40px;
      color: #fff;
      line-height: 1.2;
      margin-top: 10px;
    }
    .text {
      font-size: 26px;
      line-height: 2.2;
      padding: 0 20px;
      color: #fff;
      &.double_text {
        line-height: 56px;
        padding: 10px;
        font-size: 28px;
        display: flex;
        flex-direction: column;
        align-items: center;
        span:nth-child(1) {
          font-size: 30px;
        }
      }
    }
  }
</style>
